//
//  TrainingStatusToDataValueTransformer.m
//  EVE Mac Suite
//
//  Created by Vadim Lozko on 4/25/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "TrainingStatusToDataValueTransformer.h"


@implementation TrainingStatusToDataValueTransformer

+ (Class)transformedValueClass
{
	return [NSDate class];
}

+ (BOOL)allowsReverseTransformation
{
    return YES;
}

- (id)transformedValue:(id)value
{
	if(value == nil) return [NSData data];
	NSString* storeString;
	switch((TrainingStatus)value)
	{
		case trainingStatusRequestedSkill:	storeString = @"trainingStatusRequestedSkill";
			break;
		case trainingStatusLearnedEnough:	storeString = @"trainingStatusLearnedEnough";
			break;
		case trainingStatusCanBeLearned:	storeString = @"trainingStatusCanBeLearned";
			break;
		case trainingStatusCannotBeLearned: storeString = @"trainingStatusCannotBeLearned";
			break;
	}
	return [storeString dataUsingEncoding:NSUTF8StringEncoding];
}

- (TrainingStatus)reverseTransformedValue:(id)value
{
	NSString* TrainingStatusString = [[[NSString alloc] initWithData:(NSData*)value encoding:NSUTF8StringEncoding] autorelease];
	if([TrainingStatusString isEqualToString:@"trainingStatusRequestedSkill"])
	{
		return trainingStatusRequestedSkill;
	} else if([TrainingStatusString isEqualToString:@"trainingStatusLearnedEnough"])
	{
		return trainingStatusLearnedEnough;
	} else if([TrainingStatusString isEqualToString:@"trainingStatusCanBeLearned"])
	{
		return trainingStatusCanBeLearned;
	} else {
		return trainingStatusCannotBeLearned;
	}
}

@end
